﻿using UnityEngine;
using System.Collections;

public class PlayController : MonoBehaviour {

	public float walkSpeed = 1.0f;
	public float walkAcc = 100.0f;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void FixedUpdate () {
		float horDirection = Input.GetAxis("Horizontal");
		float velx = rigidbody.velocity.x;
		if ((horDirection > 0.0f && velx < walkSpeed)
		    || (horDirection < 0.0f && velx > -walkSpeed)) {
			rigidbody.AddForce(Vector3.right * horDirection * walkAcc * Time.deltaTime * rigidbody.mass);
		}
	}
}
